package org.csu.logistics.Service;

import org.csu.logistics.common.CommonResponse;
import org.csu.logistics.entity.Profit;
import org.csu.logistics.persistence.ProfitMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("ProfitService")
public class ProfitServiceImp implements ProfitService{
    @Autowired
    ProfitMapper profitMapper;

    @Override
    public void insert_profit(Profit profit) {
        profitMapper.insert(profit);
    }

    @Override
    public void delete_profitByOrderNum(int orderNum) {
        profitMapper.deleteById(orderNum);
    }

    @Override
    public void update_profitByOrderNum(Profit profit) {
        profitMapper.updateById(profit);
    }

    @Override
    public CommonResponse<Profit> select_profitByOrderNum(int orderNum) {
        Profit profit = profitMapper.selectById(orderNum);
        if(profit==null){
            return CommonResponse.createForError("不存在这个订单号");
        }
        return CommonResponse.createForSuccess(profit);
    }
}
